/* test_dlopen.c */
#include <stdio.h>
#include <dlfcn.h>

#define DLL_FILE_NAME "librandom.so"

int main(int argc, char const *argv[])
{
	void * handle;
	int (* func)(int);
	char * error;
	
	/* 加载动态链接库 */
	handle = dlopen(DLL_FILE_NAME, RTLD_NOW);
	if(handle == NULL)
	{
		printf("Failed to open library %s, error: %s\n", DLL_FILE_NAME, dlerror());
		return -1;
	}
	
	/* 获取特定的函数 */
	func = dlsym(handle, "obtain_random");
	printf("%d\n", func(100));

	return 0;
}

